package com.zhl.spark.core.rddtransform

import com.zhl.spark.core.BasicRdd

/**
 * @program: demos
 * @description: ${description}
 * @author: 刘振华
 * @create: 2020-12-01 10:56
 **/
object ParWithIndexRdd extends BasicRdd {
    def main(args: Array[String]): Unit = {
        test()
    }

    override def logic(): Unit = {
        val rdd = sc.parallelize(List(1,2,3,4))
        val mrdd = rdd.mapPartitionsWithIndex(
            (index, ite) => {
                ite.map((index,_))
            }
        )
        mrdd.foreach(println)
    }
}
